#include <iostream>
#include <memory>
#include "udp_server.hpp"
#include "confirmUser_forwardToAll.hpp"


//./server serverip serverport
int main(int argc, char *argv[])
{
    if (argc != 2) // if (argc != 3)
    {
        std::cout << "Usage: ./xxx serverport" << std::endl; // std::cout << "Usage: ./xxx serverip serverport" << std::endl;
        exit(-1);
    }
    // std::string lockip = argv[1];
    uint16_t lockport = std::stoi(argv[1]);


    Route route; //一个客户端，一个Route对象，一个用户
    server_t  func = std::bind(&Route::Forward, &route, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3);//route / &route都行
    // std::unique_ptr<UdpServer> up_udpser = std::make_unique<UdpServer>();//make_unique是C++14的; 编辑器识别有问题，不用管
    std::unique_ptr<UdpServer> up_udpser = std::make_unique<UdpServer>(func);//(new UdpServer());
    up_udpser->InitServer(lockport);
    up_udpser->Start();

    return 0;
}